Skip to content

Conversation

@mertcanaltin
Copy link
Member

@mertcanaltin mertcanaltin commented Dec 27, 2025

added benchmark code for isNativeError function

for: #60468 (comment)

➜  node git:(mert/create/benchmark/isNativeError) ✗ ./node benchmark/util/is-native-error.js
util/is-native-error.js n=1000000 version="native" argument="true": 320,881,319.7977036
util/is-native-error.js n=1000000 version="js" argument="true": 260,824,204.4861763
util/is-native-error.js n=1000000 version="native" argument="falsePrimitive": 338,562,200.81681514
util/is-native-error.js n=1000000 version="js" argument="falsePrimitive": 341,525,155.71839476
util/is-native-error.js n=1000000 version="native" argument="falseObject": 320,414,334.1838198
util/is-native-error.js n=1000000 version="js" argument="falseObject": 316,143,054.73226637

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added benchmark Issues and PRs related to the benchmark subsystem. util Issues and PRs related to the built-in util module. labels Dec 27, 2025
Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not confident about how useful this benchmark is


bench.start();
for (let iteration = 0; iteration < n; iteration++) {
func(arg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely being optimized.

Copy link
Member Author

@mertcanaltin mertcanaltin Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I tried to fix this by using more arguments and variable arguments. 5fcf423

@anonrig
Copy link
Member

anonrig commented Dec 27, 2025

I'm not confident about how useful this benchmark is

Any recommendations?


const func = { native: util, js: types }[version].isNativeError;

const testArgs = [args[argument], args[argument], args[argument]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this? If I'm reading correctly, the elements are all equals.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to provide more arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With

const testArg = testArgs[iteration % 3];
func(testArg)

below, I'm still not sure I understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmark Issues and PRs related to the benchmark subsystem. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants